import {HTTP} from "../utils/http-p";
import {config} from '../config'
import {getToken} from '../utils/localstorg'
class ProductModel extends HTTP{
  getUploadAddress(){
    return config.api_base_url
            +'/product/upload?token='
            + getToken()
  }

  getImageAddress(fileName){
    return `${config.api_base_url}/product/images?token=${getToken()}&pic=${fileName}`
  }

  getList(){
    return this.request({
      url:"/product/list",
      method:"get"
    })
  }
  createProduct(name,kind_id,des,pic){
    return this.request({
      url:'/product/create',
      data:{name,kind_id,des,pic},
      method:'post'
    })
  }
  editProduct(_id,name,kind_id,des,pic){
    return this.request({
      url:'/product/edit',
      data:{_id,name,kind_id,des,pic},
      method:'post'
    })
  }

  deleteProduct(_id){
    return this.request({
      url:'/product/delete',
      data:{_id},
      method:'post'
    })
  }

}

export {ProductModel}
